import BaseComponent from "./BaseComponent";

const {ccclass, property} = cc._decorator;

/**
 * 场景基类
 */
@ccclass
export default class BaseScene extends BaseComponent{

    /** 背景层 */
    protected _background:cc.Node;
    /** 显示层 */
    protected _view:cc.Node;
    /** 弹窗层 */
    protected _popup:cc.Node;
    /** 系统信息层 */
    protected _system:cc.Node;

    // onLoad () {}

    // start () {
          
    // }

    // update (dt) {}

    protected onCreate(): void
    {   
        super.onCreate();
        cc.warn("1 ==> BaseScene");
        // 创建层对象
        this.createBackgroundLayer();
        this.createViewLayer();
        this.createPopupLayer();
        this.createSystemLayer();

        // 指派层级关系 
        this.node.addChild(this._background, 0);
        this.node.addChild(this._view, 1);
        this.node.addChild(this._popup, 2);
        this.node.addChild(this._system, 3);
    }

    protected createBackgroundLayer():cc.Node
    {
        this._background = new cc.Node();
        return this._background;
    }
    
    protected createViewLayer():cc.Node
    {
        this._view = new cc.Node();
        return this._view;
    }
    
    protected createPopupLayer():cc.Node
    {
        this._popup = new cc.Node();
        return this._popup;
    }
        
    protected createSystemLayer():cc.Node
    {
        this._system = new cc.Node();
        return this._system;
    }  

    public getBackgroundLayer():cc.Node
    {
        return this._background;
    }
        
    public getViewLayer():cc.Node
    {
        return this._view;
    }
        
    public getPopupLayer():cc.Node
    {
        return this._popup;
    }
            
    public getSystemLayer():cc.Node
    {
        return this._system;
    } 
    
    protected onExit(): void
    {
        this._background = null;
        this._view = null;
        this._popup = null;
        this._system = null;

        super.onExit();
    }
    
    // 初始化当前所有事件监听
    protected initAllEventListener():void {
        // todo
    }
    
    // 移除当前所有事件监听
    protected deleteAllEventListener():void {
        // todo
    }
}
